//
//  JumpTools.m
//  GomeMarketingClient
//
//  Created by Kelly xu on 2017/3/1.
//  Copyright © 2017年 GomeFinance. All rights reserved.
//

#import "JumpTools.h"
#import "UserManager.h"
@implementation JumpTools
+(void)setRootCtrl:(UIViewController*)VC{
    [UIView transitionWithView:KeyWindow
                      duration:0.9
                       options: UIViewAnimationOptionAllowAnimatedContent | UIViewAnimationOptionLayoutSubviews |UIViewAnimationOptionTransitionCrossDissolve
                    animations:^{
                        [KeyWindow setRootViewController:VC];
                    }
                    completion:nil];
}
+(void)setRootCtrl:(UIViewController*)VC cmp:(void(^)())cmp{
    [UIView transitionWithView:KeyWindow
                      duration:0.9
                       options: UIViewAnimationOptionAllowAnimatedContent | UIViewAnimationOptionLayoutSubviews |UIViewAnimationOptionTransitionCrossDissolve
                    animations:^{
                        [KeyWindow setRootViewController:VC];
                        cmp();
                    }
                    completion:nil];
}
+(void)showNoticeLoginAlert{
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"需要登录才可以进行进一步操作?" message:nil preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *delete = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        [JumpTools logOut];
    }];
    UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
    [alert addAction:delete];
    [alert addAction:cancel];
    dispatch_async(dispatch_get_main_queue(), ^{
        [KeyWindow.rootViewController presentViewController:alert animated:YES completion:nil];
    });
}
+(void)logOut{
//    [[[NIMSDK sharedSDK] loginManager] logout:^(NSError *error) {
//        //jump to login page
//        [UserManager clearUserInfo];
//        [LoginTools sharedTools].token = @"";
//        [LoginTools sharedTools].accountId = @"";
//        CheckCodeLoginViewController *login = [[CheckCodeLoginViewController alloc]init];
//        RTRootNavigationController *nav = [[RTRootNavigationController alloc]initWithRootViewControllerNoWrapping:login];
//        [JumpTools setRootCtrl:nav];
//    }];
}
@end
